#ifndef __VIDEO_X264_ENCODER_H__
#define __VIDEO_X264_ENCODER_H__

//#include "video_codec.h"
#include <stdint.h>
#include <cstddef>
#include <memory>
#include <videoEncoder.h>

struct x264_t;
struct x264_param_t;
struct x264_picture_t;



class X264Encoder:public VideoEncoder
{
public:
	X264Encoder();
	~X264Encoder();
	
	//初始化编解码
	virtual bool Open(const encSetting& param) override;

	//结束释放
	virtual void Close() override;

	//编码
	virtual bool Encode(
		const uint8_t** yuv_data,
		uint8_t* pkt,
		size_t& pkt_size,
		bool& is_keyframe,
		bool& got_output
	) override;

	virtual bool Encode(
		const uint8_t* yuv_data,
		uint8_t* pkt,
		size_t& pkt_size,
		bool& is_keyframe,
		bool& got_output
	) override;

	//调整码率
	virtual void ReConfigure(const encSetting& param) override;

	//强制i帧
	virtual void ForceKeyframe() override;

	virtual encSetting GetConfig() override;

private:
	encSetting setting_;
	x264_t* encoder_;
	x264_param_t* encode_param_;
	x264_picture_t* frame_;
	x264_picture_t* encoded_frame_;
	bool is_open_;
	uint64_t encoded_frame_count_;
	bool enable_fixed_gop_;
	uint32_t gop_size_;
	uint64_t timestamp_;
	bool force_keyframe_;
};

#endif // __VIDEO_X264_ENCODER_H__
